package com.xingkeduo.business.operation.controller.api;

import com.xingkeduo.business.operation.controller.InitController;
import com.xingkeduo.business.operation.domain.ShopsServprodDomain;
import com.xingkeduo.pojo.dto.Servprod.ServprodMarketDTO;
import com.xingkeduo.pojo.dto.Shops.ShopsServprodDTO;
import com.xingkeduo.pojo.query.ShopsServprodQuery;
import com.xingkeduo.pojo.table.ShopsServprodTable;
import com.xingkeduo.tool.ResponseUtils;
import com.xingkeduo.util.pojo.exception.SystemException;
import com.xingkeduo.util.tool.ReturnUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.xingkeduo.tool.OperaConstants.API_URL_PREFIX;

/**
 * 门店服务商品管理
 *
 * @author chenxiangda <chenxiangda@xingkeduo.com>
 * @version id:v0.1 ${date}${time}
 * @package BeautyOS
 * @copyright Copyright (c) XKD 2019
 */
@RestController
@RequestMapping(API_URL_PREFIX +"/shopsServprod")
public class ShopsServprodApiController extends InitController {

    @Autowired
    private ShopsServprodDomain shopsServprodDomain;


    /**
     * 根据店铺ID查询BARBER价格
     */
    @GetMapping(value = "/getBarberPrice")
    public ResponseUtils doGet(ShopsServprodQuery shopsServprodQuery) {
        returnUtil = new ReturnUtil();
        try {
            List<ShopsServprodTable> servprodPrice = shopsServprodDomain.getBarberPrice(shopsServprodQuery);
            return ResponseUtils.getSuccess(servprodPrice);
        } catch (Throwable throwable) {
            throwable.printStackTrace();
            return ResponseUtils.error(throwable.getMessage(), SystemException.Type.DEFAULT.toString());
        }
    }


    /**
     * 根据店铺ID组装店铺服务价格和营销系统的价格
     */
    @GetMapping(value = "/getOrderPrice")
    public ResponseUtils doGetOrderPrice(Long shopId) {
        returnUtil = new ReturnUtil();
        try {
            List<ServprodMarketDTO> servprodPrice = shopsServprodDomain.getOrderPrice(shopId);
            return ResponseUtils.getSuccess(servprodPrice);
        } catch (Throwable throwable) {
            throwable.printStackTrace();
            return ResponseUtils.error(throwable.getMessage(), SystemException.Type.DEFAULT.toString());
        }
    }
//    @RequestMapping("/getShopsServprodList")
    //API获取列表查看
    @GetMapping(value = "/getShopsServprodList")
    public ResponseUtils doGetShopsServprodList(ShopsServprodQuery shopsServprodQuery) {
        returnUtil = new ReturnUtil();
        try {
            List<ShopsServprodDTO> shopsServprodList = shopsServprodDomain.getShopsServprodList(shopsServprodQuery);
            return ResponseUtils.getSuccess(shopsServprodList);
        } catch (Throwable throwable) {
            throwable.printStackTrace();
            return ResponseUtils.error(throwable.getMessage(), SystemException.Type.DEFAULT.toString());
        }
    }
//
//    //查看
//    @RequestMapping(value = "/lists/{urlParam:.+}", method = RequestMethod.GET)
//    public String doGetLists(@PathVariable String urlParam) {
//        returnUtil = new ReturnUtil();
//        try {
//            ShopsServprodQuery shopsServprodQuery =  JSON.parseObject(urlParam,ShopsServprodQuery.class);
//
//            List<ShopsServprodTable> shopsServprodTableList = shopsServprodDomain.getShopsServprodByShopsId(shopsServprodQuery);
//
//            return returnUtil.getSuccess(ShopsServprodJson.toJson(shopsServprodTableList));
//
//        } catch (Throwable throwable) {
//            return dealException(throwable, returnUtil);
//        }
//    }

}
